package org.example.common.web.config; /**
 * Created by Wangxf on 2021/4/23.
 */


import org.example.common.web.interceptor.GrayTagRuleInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //自定义的拦截器
    @Bean
    public GrayTagRuleInterceptor getGrayTagRuleInterceptor() {
        return new GrayTagRuleInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        InterceptorRegistration registration = registry.addInterceptor(getGrayTagRuleInterceptor());
        //拦截全部
        registration.addPathPatterns("/**");
    }

}
